package com.apps.epocket.stripes.config;



import com.apps.epocket.stripes.BaseActionBean;
import com.apps.epocket.stripes.LoginActionBean;
import net.sourceforge.stripes.action.RedirectResolution;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;


public class AuthRequiredIntereptor implements MethodInterceptor {
    
    public Object invoke(MethodInvocation invocation) throws Throwable {
        BaseActionBean bean = (BaseActionBean) invocation.getThis();

        if (!bean.getContext().isLoggedIn()) {
            return new RedirectResolution(LoginActionBean.class);
        } else {
            String exp = "";
            try {
                return invocation.proceed();
            } catch (Exception ex) {
                exp = ex.getMessage();
                throw ex;
            } finally {
            }
        }
    }

}
